﻿
function createCarTreePanel() {
    carTree = new Ext.tree.TreePanel({
        el: 'tree', //渲染到,
        anchor: '100%',
        layout: 'fit', 
        useArrows: true,
        autoHeight: true,
        split: true,
        lines: true,
        //height: 360,
        minSize: 150,
        autoScroll: true,
        animate: true,
        enableDD: true,
        border: false,
        containerScroll: true,
        rootVisible: false,
        loader: new Ext.tree.TreeLoader({
            dataUrl: './Services/Handler.ashx?clientNo=' + userClientNo + '&currentService=' + currentService
        })
    });

    var root = new Ext.tree.AsyncTreeNode({
        text: '我的车辆',
        //draggable: true,
        id: 'lhyh'
    });
    carTree.setRootNode(root);
    carTree.render();
    root.expand();
    //click
    carTree.on('dblclick', function(node) {
        markerclick(node.attributes.CardNo);
    });
    carTree.on('contextmenu', treeshowmenu);

    var detailsPanel = {
        id: 'details-panel',
        title: '车辆详细信息',
        region: 'center',
        bodyStyle: 'padding-bottom:15px;background:#eee;',
        autoScroll: true,
        html: '<p class="details-info">显示车辆详细静态和动态信息</p>'
    };


    return new Ext.Panel({
            anchor: '100%',
            layout: 'fit',
            autoScroll: true,
            region: 'west',
            id: 'west-panel', 
            title: '控制台',
            split: true,
            width: 200,
//            minSize: 175,
//            maxSize: 400,
            collapsible: true,
            margins: '0 0 0 5',
//            layout: {
//                type: 'accordion',
//                animate: true
//            },
            items: [
//            {
//                contentEl: 'west',
//                title: '车辆信息',
//                border: false,
//                iconCls: 'nav',
//                items: [
                carTree
//                ]
//            }
            ]
        });
            
            
//    return new Ext.Panel({
//        region: 'west',
//        id: 'west-panel', 
//        title: '控制台',
//        split: true,
//        width: 200,
//        minSize: 175,
//        maxSize: 400,
//        collapsible: true,
//        margins: '0 0 0 5',
//        layout: {
//            type: 'accordion',
//            animate: true
//        },
//        items: [{
//            contentEl: 'west',
//            title: '车辆信息',
//            border: false,
//            iconCls: 'nav',
//            items: [carTree, detailsPanel]
//        }, {
//            title: '查询统计',
//            html: '<p>Some settings in here.</p>',
//            border: false,
//            iconCls: 'settings'
//        }]
//        });
    }

    function treeshowmenu(node, e) {
        if (hisPlayWin == null) {
            if (node.attributes.NodeType == 0) {
                curVID = node.id;
                curCardNo = node.attributes.CardNo;
                curLicensePlate = node.text;
                var coords = e.getXY();
                rightMenu.showAt([coords[0], coords[1]]);
            }
        }
    }